package com.zhou.common.mybatis.template.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @author fenghua
 * @version 1.0
 * @date 2023/2/16 5:35 下午
 */
@Slf4j
@Component
public class MybatisDataFillHandler implements MetaObjectHandler {


    //插入时的填充策略
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "creatorId", String.class, "creatorId");
        this.strictInsertFill(metaObject, "creatorName", String.class, "creatorName");
        this.strictInsertFill(metaObject, "modifierId", String.class, "modifierId");
        this.strictInsertFill(metaObject, "modifierName", String.class, "modifierName");
    }

    //更新时的填充策略
    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "modifierId", String.class, "modifierId");
        this.strictUpdateFill(metaObject, "modifierName", String.class, "modifierName");
    }

}
